#include <hidef.h> /* for EnableInterrupts macro */
#include "Headers/derivative.h" /* include peripheral declarations */
#include "Headers/232.h"

/*
* this function is for set up the rs232 protocol
* parameters
*          baudrate-------> use the defined values located in the define.h
*          flags----------> configuration for the rs232
* does not return 
* NOTE --
*/
void setup_232(word baudrate, char flags){
  //baudrate = bsclk / (16 * SCIxBDH, SCIxBDL)
  SCI2BD = baudrate;
  SCI2C1 = flags;
  SCI2C2 = 0x0C;//enable the rx and tx
}
char send_232(char *dato){
  char rta_fc = 0;
  int x = 0;
  while(*dato != 0){
    while(!SCI2S1_TDRE){
      __RESET_WATCHDOG();
      //x++;
    }
    SCI2D = *dato++;
  }
  return rta_fc;
}